package com.diaohw.module.system.obj.tables;

import com.diaohw.platform.framework.db.flex.obj.tables.BaseTableDef;
import com.mybatisflex.core.query.QueryColumn;

import java.io.Serial;

/**
 * 菜单 表定义层。
 *
 * @author D-Hw
 * @since 2024-11-15 18:22:15
 */
public class MenuDef extends BaseTableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 菜单
     */
    public static final MenuDef MENU = new MenuDef();

    /**
     * 图标
     */
    public final QueryColumn ICON = new QueryColumn(this, "ICON");

    /**
     * 排序
     */
    public final QueryColumn SORT = new QueryColumn(this, "SORT");

    /**
     * 状态;0：禁用，1：启用
     */
    public final QueryColumn STATE = new QueryColumn(this, "STATE");

    /**
     * 备注
     */
    public final QueryColumn REMARK = new QueryColumn(this, "REMARK");

    /**
     * 菜单名称
     */
    public final QueryColumn MENU_NAME = new QueryColumn(this, "MENU_NAME");

    /**
     * 父级菜单ID
     */
    public final QueryColumn PARENT_ID = new QueryColumn(this, "PARENT_ID");

    /**
     * 组件地址
     */
    public final QueryColumn COMPONENT = new QueryColumn(this, "COMPONENT");

    /**
     * 第几级
     */
    public final QueryColumn MENU_LEVEL = new QueryColumn(this, "MENU_LEVEL");

    /**
     * 路由
     */
    public final QueryColumn MENU_ROUTE = new QueryColumn(this, "MENU_ROUTE");


    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{PARENT_ID, MENU_NAME, MENU_LEVEL, MENU_ROUTE, ICON, SORT, COMPONENT, REMARK, STATE};

    public MenuDef() {
        super("", "MENU");
    }

    private MenuDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public MenuDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new MenuDef("", "MENU", alias));
    }

}
